"use strict";
// Class definition

var addSaveWork = function () {

    var eventHandler = function () {
        $('.has-border li input').off("input propertychange");
        $('.has-border li input').on("input propertychange",changeInput);
    };

    var changeInput = function () {
        var inputGroups = $(this).parents('ul').find('input:not(.total)');
        var totalInput = $(this).parents('ul').find('input.total');
        var total = 0;
        inputGroups.each(function (index, item) {
            total += Number($(item).val());
        });
        totalInput.val(total);
    };

    var initSaveWork = function () {
        $('.k_selectpicker').selectpicker();

        $('#fill_in_date').datetimepicker();
    };


    return {
        // public functions
        init: function () {
            eventHandler();
            initSaveWork();
        }
    };
}();

jQuery(document).ready(function () {
    addSaveWork.init();
});
